package cn.edu.hbvtc.qms.persist.hibernate;

import java.util.List;

import cn.edu.hbvtc.qms.domain.Criteria;
import cn.edu.hbvtc.qms.persist.ICriteriaDao;

public class HibernateCriteriaDao extends HibernateAbstractDao<Criteria, Integer>
		implements ICriteriaDao {

	private static final long serialVersionUID = 1L;

	public HibernateCriteriaDao() {
		super(Criteria.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Criteria findCriteriaByPurposeAndEnabled(String purpose) {
		List<Criteria> criteriaList = this.getHibernateTemplate().find("from Criteria c where c.purpose = ? and c.enabled = 1", purpose);
		Criteria criteria = null;
		if (criteriaList != null && criteriaList.size() > 0) {
			criteria = criteriaList.get(0);
		}
		return criteria;
	}
	
}
